clear all
load ParEst_eh1_time0_Mex ParEst_eh1_time0_Mex
load trans_time1_age0_eh1_comp1.out
Chute =ParEst_eh1_time0_Mex;
HandleLo = @Principal_A2_n;

Dij=trans_time1_age0_eh1_comp1'; % Read transition moments

Dnf_1	 =	Dij(1);
Dni_1	 =	Dij(2);
Dfn_1	 =	Dij(3);
Dff_1	 =	0;
Dfi_1	 =	Dij(4);
Din_1	 =	Dij(5);
Dii_1	 =	0;
Dif_1  =	Dij(6);
Dni_df_1 = Dij(7);    % Transitions for spouse 2 (spouse) from not working to informal when spouse 1 (head) loses job in formal sector
Dni_di_1 = Dij(8);    % Transitions for spouse 2 (spouse) from not working to informal when spouse 1 (head) loses job in informal sector
Dnf_2	 =	Dij(9);
Dni_2	 =	Dij(10);
Dfn_2	 =	Dij(11);
Dff_2	 =	0;
Dfi_2	 =	Dij(12);
Din_2	 =	Dij(13);
Dii_2	 =	0;
Dif_2  =	Dij(14);
Dni_df_2 = Dij(15);
Dni_di_2 = Dij(16);
Lower =[Dfn_1,Din_1,Dnf_1,Dni_1,Dfi_1,Dif_1,Dfn_2,Din_2,...
     Dnf_2,Dni_2,Dfi_2,Dif_2,Dni_df_2,Dni_di_2,Dni_df_1,Dni_di_1];
LoBo =zeros(1,24);
LoBo = [Lower, 0.1, 0.1, 0.1, 0.1, -10, -2, -10, -10];
HiBo = [.81 .81 .81 .991 .81 .81 .81 .81 .81 .81 .81 .81 .91 .81 .91 .91 10 10 10 10 -4 4 0 0];
                 options = saoptimset( ...
                     'PlotFcn',{@saplotbestf,@saplottemperature,@saplotf,@saplotbestx,@saplotx},...
                     'TolFun',6000,'ReannealInterval',4, ...
                     'InitialTemperature', 10^2*[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10 10 10 10 6 6 10 10], ...
                     'TemperatureFcn', @temperaturefast, 'StallIterLimit', 2000); %default 14*10^2*
[x,fval,exitflag,output]  = simulannealbnd(HandleLo, Chute, LoBo, HiBo, options)
ParEst_eh1_time0_Mex = x;
save ParEst_eh1_time0_Mex ParEst_eh1_time0_Mex
